#pragma once
#include"HashTable.h"

template<class K, class V, class Hash = HashFunc<K>>
class MyHashMap
{
	struct KeyofT
	{
		const K& operator()(const pair<K, V>& kv)
		{
			return kv.first;
		}
	};
public:
	typedef typename hash_bucket::HashTable<K, pair<const K, V>, KeyofT, Hash>::iterator iterator;

	iterator begin()
	{
		return _ht.begin();
	}
	iterator end()
	{
		return _ht.end();
	}


	pair<iterator, bool> insert(const  pair<K, V>& kv)
	{
		return _ht.Insert(kv);
	}
	iterator find(const K& key)
	{
		return _ht.Find(key);
	}

	bool erase(const K& key)
	{
		return _ht.Erase(key);
	}

	V& operator[](const K& key)
	{
		pair<iterator, bool>  ret = _ht.Insert(make_pair(key, V()));
		return ret.first->second;
	}
	void Print()
	{
		_ht.Print();
	}



private:
	hash_bucket::HashTable<K, pair<const K, V>,KeyofT, Hash> _ht;

};